﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UIT.Web.Controls.Html;

namespace UIT.Web.Renderers
{
    public class ScriptRenderer : HtmlControlRenderer, IControlRenderer<Script>
    {
        #region IRenderer<Script> Members

        public void Render(Script control)
        {
            RenderBeginTag(control);

            writer.WriteAttributeString("type", "text/javascript");

            if (!string.IsNullOrEmpty(control.Source))
                writer.WriteAttributeString("src", control.Source);

            if (!string.IsNullOrEmpty(control.Code))
                writer.WriteString(control.Code);

            RenderEndTag(control);
        }

        #endregion

        #region IVisitor<Script> Members

        public void Visit(Script visitable)
        {
            Render(visitable);
        }

        #endregion
    }
}
